home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
catn
/
selection.n
< prev
next >
Wrap
Text File
|
1994-09-20
|
7KB
|
199 lines
selection(n) Tk Commands
_________________________________________________________________
NAME
selection - Manipulate the X selection
SYNOPSIS
selection _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
_________________________________________________________________
DESCRIPTION
This command provides a Tcl interface to the X selection
mechanism and implements the full selection functionality
described in the X Inter-Client Communication Conventions
Manual (ICCCM), except that it supports only the primary
selection.
The first argument to selection determines the format of the
rest of the arguments and the behavior of the command. The
following forms are currently supported:
selection clear _w_i_n_d_o_w
If there is a selection anywhere on _w_i_n_d_o_w's display, |
clear it so that no window owns the selection anymore. |
Returns an empty string.
selection get ?_t_y_p_e?
Retrieves the value of the primary selection and
returns it as a result. Type specifies the form in
which the selection is to be returned (the desired
``target'' for conversion, in ICCCM terminology), and
should be an atom name such as STRING or FILE_NAME;
see the Inter-Client Communication Conventions Manual
for complete details. Type defaults to STRING. The
selection owner may choose to return the selection in
any of several different representation formats, such
as STRING, ATOM, INTEGER, etc. (this format is dif-
ferent than the selection type; see the ICCCM for all
the confusing details). If the selection is returned
in a non-string format, such as INTEGER or ATOM, the
selection command converts it to string format as a
collection of fields separated by spaces: atoms are
converted to their textual names, and anything else is
converted to hexadecimal integers.
selection handle _w_i_n_d_o_w _c_o_m_m_a_n_d ?_t_y_p_e? ?_f_o_r_m_a_t?
Creates a handler for selection requests, such that
_c_o_m_m_a_n_d will be executed whenever the primary selection
is owned by _w_i_n_d_o_w and someone attempts to retrieve it
in the form given by _t_y_p_e (e.g. _t_y_p_e is specified in
the selection get command). _T_y_p_e defaults to STRING. |
If _c_o_m_m_a_n_d is an empty string then any existing handler |
Tk 1
selection(n) Tk Commands
for _w_i_n_d_o_w and _t_y_p_e is removed.
When the selection is requested and _w_i_n_d_o_w is the
selection owner and _t_y_p_e is the requested type, _c_o_m_m_a_n_d
will be executed as a Tcl command with two additional
numbers appended to it (with space separators). The
two additional numbers are _o_f_f_s_e_t and _m_a_x_B_y_t_e_s: _o_f_f_s_e_t
specifies a starting character position in the selec-
tion and _m_a_x_B_y_t_e_s gives the maximum number of bytes to
retrieve. The command should return a value consisting
of at most _m_a_x_B_y_t_e_s of the selection, starting at posi-
tion _o_f_f_s_e_t. For very large selections (larger than
_m_a_x_B_y_t_e_s) the selection will be retrieved using several
invocations of _c_o_m_m_a_n_d with increasing _o_f_f_s_e_t values.
If _c_o_m_m_a_n_d returns a string whose length is less than
_m_a_x_B_y_t_e_s, the return value is assumed to include all of
the remainder of the selection; if the length of
_c_o_m_m_a_n_d's result is equal to _m_a_x_B_y_t_e_s then _c_o_m_m_a_n_d will
be invoked again, until it eventually returns a result
shorter than _m_a_x_B_y_t_e_s. The value of _m_a_x_B_y_t_e_s will
always be relatively large (thousands of bytes).
If _c_o_m_m_a_n_d returns an error then the selection
retrieval is rejected just as if the selection didn't |
exist at all.
The _f_o_r_m_a_t argument specifies the representation that
should be used to transmit the selection to the reques-
ter (the second column of Table 2 of the ICCCM), and
defaults to STRING. If _f_o_r_m_a_t is STRING, the selection
is transmitted as 8-bit ASCII characters (i.e. just in
the form returned by _c_o_m_m_a_n_d). If _f_o_r_m_a_t is ATOM, then
the return value from _c_o_m_m_a_n_d is divided into fields
separated by white space; each field is converted to
its atom value, and the 32-bit atom value is transmit-
ted instead of the atom name. For any other _f_o_r_m_a_t,
the return value from _c_o_m_m_a_n_d is divided into fields
separated by white space and each field is converted to
a 32-bit integer; an array of integers is transmitted
to the selection requester.
The _f_o_r_m_a_t argument is needed only for compatibility
with selection requesters that don't use Tk. If the Tk
toolkit is being used to retrieve the selection then
the value is converted back to a string at the request-
ing end, so _f_o_r_m_a_t is irrelevant.
selection own ?_w_i_n_d_o_w? ?_c_o_m_m_a_n_d?
If _w_i_n_d_o_w is specified, then it becomes the new selec- |
tion owner and the command returns an empty string as |
result. The existing owner, if any, is notified that |
it has lost the selection. If _c_o_m_m_a_n_d is specified, it |
Tk 2
selection(n) Tk Commands
is a Tcl script to execute when some other window |
claims ownership of the selection away from _w_i_n_d_o_w. If |
neither _w_i_n_d_o_w nor _c_o_m_m_a_n_d is specified then the com- |
mand returns the path name of the window in this appli- |
cation that owns the selection, or an empty string if |
no window in this application owns the selection.
KEYWORDS
clear, format, handler, ICCCM, own, selection, target, type
Tk 3